package Buildings.threads;
import java.util.Iterator;
import Interfaces.*;
public class SequentalCleaner implements Runnable{
    Thread me;
    ElementalSemaphore sema;
    public void run(){
        Iterator it=((Floor)sema.getObj()).iterator();
        int i=0;
        while(it.hasNext()){
            sema.enter();
            Space sp=(Space)it.next();
            System.out.println(Thread.currentThread()+"Уборка помещения номер "+i+" площадью "+sp.getHowMuchArea());
            i++;
            sema.leave();
        }
    }
    public SequentalCleaner(ElementalSemaphore s){
        sema=s;
        me=new Thread (this,"Поток чистильщик");
        me.start();
    }
    public SequentalCleaner(ElementalSemaphore s, String d){
        sema=s;
        me=new Thread (this,d);
        me.start();
    }
}
